package com.example.spring_seatreservation.controller;

import com.example.spring_seatreservation.Bean.R;
import com.example.spring_seatreservation.entity.Role;
import com.example.spring_seatreservation.mapper.RoleMapper;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/role")
@AllArgsConstructor
public class RoleController {

    private final RoleMapper roleMapper;

    @GetMapping("getRoleList")
    public List<Role> getRoleList(){
        return roleMapper.getRoleList();
    }

    @PostMapping("addRole")
    public Map<String, Object> addRole(@RequestBody Role role){
        roleMapper.insert(role);
        return new R().ok().builder();
    }

    @PostMapping("updRole")
    public Map<String, Object> updRole(@RequestBody Role role){
        roleMapper.update(role);
        return new R().ok().builder();
    }
}
